#ifndef __UH_DEV__H_
#define __UH_DEV__H_

#ifdef __cplusplus
extern "C"{
#endif

#include "Stdusb.h"

enum
{
	 BUS_RESET_TIMER_ID = 1
	,CONNECT_TIMER_ID
	,SETADDR_TIMER_ID
}


/**
 * \brief Enumeration status
 * Used in UHC_ENUM_EVENT() callback
 * when a USB device enumeration is completed.
 */
typedef enum {
	//! Device is enumerated.
	//! The supported USB device interfaces has been enabled.
	UHC_ENUM_SUCCESS = 0,

	//! None of the interfaces are supported by the UHIs.
	UHC_ENUM_UNSUPPORTED,

	//! Device power is not supported.
	UHC_ENUM_OVERCURRENT,

	//! A problem occurred during USB enumeration.
	UHC_ENUM_FAIL,

	//! USB hardware can not support it. Not enough free pipes.
	UHC_ENUM_HARDWARE_LIMIT,

	//! USB software can not support it. Implementation limit.
	UHC_ENUM_SOFTWARE_LIMIT,

	//! USB software can not support it. Not enough memory.
	UHC_ENUM_MEMORY_LIMIT,

	//! The device has been disconnected during USB enumeration.
	UHC_ENUM_DISCONNECT,
} uhc_enum_status_t;

#define UHC_DEVICE_ENUM_ADD 1 // Static without USB HUB

#define MAX_CONFIG_DESC_SIZE 128

enum
{
	HOST_STATE_INIT
	,HOST_STATE_SETADDR
	,HOST_STATE_CONFIG
};

//Usb host device struct
typedef struct _UhDev
{
	MsgIf	m_Base;

	uint8	m_State;
	
	usb_dev_desc_t dev_desc;

	// USB address
	uint8_t address;

	// USB speed
	uhd_speed_t speed;

	//! USB current configuration descriptor
	uint8 conf_desc[MAX_CONFIG_DESC_SIZE];

	CtrlPipe	m_CtrlPipe;
	BlkInPipe	m_BlkInPipe;
	BlkOutPipe	m_BlkOutPipe;
}UhDev;

void UhDev_init(UhDev* pUhDev);

#ifdef __cplusplus
}
#endif

#endif


